<?php

// 消息项目撤回（创业者）
// DELETE msg.undo

namespace app\api\resource\project\msg;
use think\Db;
use think\Session;

class Undo
{
    // 方法
    public $_method = ['DELETE'];
    // 前置
    public $_pre    = ['login','isCyz'];
    // 描述
    public $_description = '消息项目撤回（创业者）';
    // 参数
    public $_param  = [
        'id' => '消息主键',
    ];
    // 返回
    public $_return = [
        204 => '操作成功',
        422 => '消息主键必须',
        500 => '服务器错误',
    ];

    public function run(&$request)
    {
        $id         = $request->put('id/d',0);
        $memberId   = Session::get('member.id');

        if (0 == $id) return [422,'消息主键必须'];

        $num = Db::name('project_push')->where('id',$id)->where('from_member_id',$memberId)->delete();

        return ($num > 0) ? [ 204,'' ] : 500;
    }
}